<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            width: 1000px;
            margin: 100px auto;
            border-collapse: collapse;
        }

        table thead {
            background-color: #7ec9ec;
        }

        table tbody tr {
            height: 30px;
            border-bottom: 1px solid #ccc;
        }

        table tbody tr td {
            color: #4f4fb9;
            line-height: 30px;
            text-align: center;
        }
    </style>
</head>

<body>
    <table>
        <thead>
            <tr>
                <th><input type="checkbox" name="" id=""></th>
                <th>代码</th>
                <th>名称</th>
                <th>最新公布净值</th>
                <th>累计净值</th>
                <th>前单位净值</th>
                <th>净值增长率</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th><input type="checkbox" name="" id=""></th>
                <td>962t00+</td>
                <td>P20</td>
                <td>620'1</td>
                <td>S20'L</td>
                <td>亲单巩工维半自少8事季能泌</td>
                <td>9ZSE00</td>
            </tr>
            <tr>
                <th><input type="checkbox" name="" id=""></th>
                <td>962t00+</td>
                <td>P20</td>
                <td>620'1</td>
                <td>S20'L</td>
                <td>亲单巩工维半自少8事季能泌</td>
                <td>9ZSE00</td>
            </tr>
            <tr>
                <th><input type="checkbox" name="" id=""></th>
                <td>962t00+</td>
                <td>P20</td>
                <td>620'1</td>
                <td>S20'L</td>
                <td>亲单巩工维半自少8事季能泌</td>
                <td>9ZSE00</td>
            </tr>
            <tr>
                <th><input type="checkbox" name="" id=""></th>
                <td>962t00+</td>
                <td>P20</td>
                <td>620'1</td>
                <td>S20'L</td>
                <td>亲单巩工维半自少8事季能泌</td>
                <td>9ZSE00</td>
            </tr>
            <tr>
                <th><input type="checkbox" name="" id=""></th>
                <td>962t00+</td>
                <td>P20</td>
                <td>620'1</td>
                <td>S20'L</td>
                <td>亲单巩工维半自少8事季能泌</td>
                <td>9ZSE00</td>
            </tr>
        </tbody>
        <script>
            var checkbox = document.querySelectorAll('input');
            checkbox[0].onclick = function () {
                var all = checkbox[0].checked;
                if (all) {
                    for (var i = 0; i < checkbox.length; i++) {
                        checkbox[i].checked = true;
                    }
                }
                else {
                    for (var i = 0; i < checkbox.length; i++) {
                        checkbox[i].checked = false;
                    }
                }
            }
            for (var i = 1; i < checkbox.length; i++) {
                checkbox[i].onclick = function () {

                    var all = true;
                    for (var i = 1; i < checkbox.length; i++) {
                        if (checkbox[i].checked == false) {
                            all = false;
                            break;
                        }
                    }
                    console.log(all);
                    checkbox[0].checked = all;


                }
            }

        </script>
</body>

</html>